// 用户相关Api
import request from '../utils/request.js'
// 导入axios
import axios from 'axios'

// 登录的Api接口
export const loginApi = data => {
    return request.post('/v1_0/authorizations', data)
}

// 获取用户信息基本信息
export const getUserInfoApi = () => {
    return request.get('/v1_0/user')
}

// 获取用户简介信息
export const getUserProfileApi = () => {
    return request.get('/v1_0/user/profile')
}

// 更新用户简介信息Api Profile是简介的意思
export const updateUserProfileApi = (obj) => {
    return request.patch('/v1_0/user/profile', obj)
}

// 修改头像的APi
export const updateAvatarApi = fd => {
    return request.patch('/v1_0/user/photo', fd)
}

// 换取tokenApi
export const exchangeTokenApi = (reftoken) => {
    // 要基于axios发请求，request设置了请求头了
    return axios({
        method: 'put',
        // 填写完整的url地址
        url: 'http://toutiao-app.itheima.net/v1_0/authorizations',
        // 请求头对象
        headers: {
            Authorization: `Bearer ${reftoken}`
        }
    })
}
